<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<style type="text/css">
    .error{
        color:red;
    }
    .show1{
        display:none;
    }
</style>
<head>
    <title>用户注册</title>
    <link rel="stylesheet" href="resource/statics/css/materialize.css">
    <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <meta charset="utf-8">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
</head>
<body style="background: url(resource/images/book4.jpg);-webkit-background-size: cover;background-size: 100% 100%;">
<nav style="background-color: rgba(176,196,222,0.7);">
    <div class="nav-wrapper">
        <a href="#" class="brand" style="font-weight: bold; font-size: 1.35rem;">三峡大学小书屋</a>
        <ul id="nav-mobile" class="right hide-on-med-and-down">
            <li><a href="" style="font-size: 1.3rem;font-weight: bold;">更多帮助</a></li>
        </ul>
    </div>
</nav>
<div class="container">
    <div class="row" style="margin: 40px 0 40px 0;">
        <div class="col s6 offset-s3 card-panel" style="background-color: rgba(255,255,255,0.8);">
            <div class="row" style="display: flex; justify-content: center; align-items: center;">
                <p style="font-family: 微软雅黑; align-items: center; color: rgb(70,130,180); font-size: 25px;font-weight: bold;">用户注册信息</p>
            </div>
            <div class="row">
                <form class="col s12" action="register.do" method="post">
                    <div class="row" style="font-weight: bold;">
                        <div class="input-field col s10 offset-s1">
                            <i class="material-icons prefix" >account_circle</i>
                            <input type="text" placeholder="姓名" id="name" name="name"/>
                            <span id="spanname" class="error show1">(姓名应该在2到10个字符之内)</span>
                        </div>
                        <div class="input-field col s10 offset-s1">
                            <i class="material-icons prefix">perm_identity</i>
                            <input type="text" placeholder="用户名" id="username"  name="username"/>
                            <span id="spanusername" class="error show1">(用户名应该在2到10个字符之内)</span>

                        </div>
                        <div class="input-field col s10 offset-s1">
                            <i class="material-icons prefix">phone</i>
                            <input type="text" placeholder="电话" id="phone" name="phone"/>
                            <span id="spanphone" class="error show1">(请输入正确的手机号码)</span>

                        </div>
                        <div class="input-field col s10 offset-s1">
                            <i class="material-icons prefix">address</i>
                            <input type="text" placeholder="邮箱" id="email" name="email"/>
                        </div>
                        <div class="input-field col s10 offset-s1">
                            <input type="password" placeholder="请设置密码" id="password" name="password"/>
                            <span id="spanpassword" class="error show1">(密码应该在6到15个字符之内)</span>

                        </div>
                        <div class="input-field col s10 offset-s1">
                            <input placeholder="请确认密码" type="password" id="spassword"/>
                            <span id="spanspassword" class="error show1">(两次密码不一致)</span>

                        </div>
                        <div class="button" style="text-align: center;">
                            <button class="btn waves-effect waves-light" type="submit" name="action" disabled="disabled"  id="submit" style="background-color: rgb(70,130,180);">提交
                                <i class="material-icons right">send</i>
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<footer class="page-footer" style="background-color: #88a6c0; padding-top:0px;">
    <div class="footer-copyright" style="/*background-color: #88a6c0;*/">
        <div class="container" style="font-family: 微软雅黑;font-size: 1.35rem;">
            ©不太靠谱的五人组
            <a class="grey-text text-lighten-4 right" href="#">无法注册</a>
        </div>
    </div>
</footer>
<script type="text/javascript">
    $("#username").keyup(function(){

        if($.trim($("#password").val()).length != "")
        {
            if($.trim($("#username").val()).length == "" || $.trim($("#username").val()).length < 2 || $.trim($("#username").val()).length > 10) {
                $("#spanusername").css("display","block");
                $("#submit").attr("disabled","disabled");
            } else {
                $("#spanusername").css("display","none");
                $("#submit").removeAttr("disabled");
            }
        }else {
            if($.trim($("#username").val()).length == "" || $.trim($("#username").val()).length < 2 || $.trim($("#username").val()).length > 10) {
                $("#spanname").css("display","block");
            } else {
                $("#spanname").css("display","none");
            }
        }
    });
    $("#password").keyup(function(){
        if(($.trim($("#username").val()).length == "" || $.trim($("#username").val()).length < 2 || $.trim($("#username").val()).length > 10)||
            ($.trim($("#password").val()).length == "" || $.trim($("#password").val()).length < 6 || $.trim($("#password").val()).length > 15)
            )
        {
            $("#spanpassword").css("display","block");

        } else {
            $("#spanpassword").css("display","none");

        }
    });
    //检查确认密码 与密码的一致性
    $("#spassword").keyup(function(){
        //alert($.trim($(this).val()).length);
        if($.trim($(this).val()) != $.trim($("#password").val())) {
            $("#spanspassword").css("display","block");
            $("#submit").attr("disabled","disabled");
        } else {
            $("#spanspassword").css("display","none");
            $("#submit").removeAttr("disabled");
        }
    });
        //检查姓名的正确性
        $("#name").keyup(function(){
            //alert($.trim($(this).val()).length);
            if($.trim($(this).val()).length == "" || $.trim($(this).val()).length < 2 || $.trim($(this).val()).length > 10) {
                $("#spanname").css("display","block");
            } else {
                $("#spanname").css("display","none");
            }
        });
        //检查手机号的正确性
        $("#phone").keyup(function(){
            //alert($.trim($(this).val()).length);
            if($.trim($(this).val()).length == "" || $.trim($(this).val()).length != 11) {
                $("#spanphone").css("display","block");
            } else {
                $("#spanphone").css("display","none");
            }
        });

</script>

</body>
</html>
